<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
	<style>
		label{	color:#00F; 	line-height:21px; 	font-weight:bold; 	height:21px; 	vertical-align:middle;	font-size:12px;}
	</style>
</head>
<body id="main_page">
<div class="container"> 
       <form enctype="multipart/form-data"  method="post" id="frm">
                	<input type="hidden" name="p" value="{$NowPage}" />
                    <div class="table">
                    <div class="toolbars">
                        <li class="toolbar"><a id="selectall" onclick="CheckAll()"  title="全选">全选</a></li>
                        <li class="toolbar"><a id="btnSaveAll" onclick="startSend(1)"  title="发放优惠券" target="_self">&nbsp;&nbsp;发放优惠券</a></li>
                        <li class="toolbar toolbarform" id="toolbarleft">
                            <label>会员名称/手机/Email</label>
                            <input type="text" class='textinput' name="Keywords" style="width:110px" value="{$Keywords}" id="Keywords" />
                            <input id="btnSeek" class="btnToolbarForm" type="submit" value="查询" onclick="Search()">
                        </li>
                        <li class="toolbar toolbarform">
                        	<label>按会员组发放</label>
                        	<select id="MemberGroupID">
                                <option value="-1">全部分组</option>
                                <volist id="mg" name="MemberGroup">
                                	<option value="{$mg.MemberGroupID}" >{$mg.MemberGroupName}</option>
                                </volist>
                            </select>
                            <a id="btnCheckDb" class="btnToolbarForm" style="float:right;" onclick="startSend(2)">&nbsp;&nbsp;发放</a>
                        </li>
                    </div>
                    <table class="datatable" id="datatable">
                    <tr>
                        <th width="35px"  nowrap="nowrap">选中</th>
                        <th width="60px">会员ID</th>
                        <th>会员名称</th>
                        <th width="66px">真实姓名</th>
                        
                        <th width="95px" >手机</th>
                        <th width="125px">Email</th>
                        <th width="100px">所属分组</th>
                    </tr>  
                    <notempty name="Data">                
                        <volist name="Data" id="d">
                            <tr>
                                <td><input class="checkrow" type="checkbox" name="id[]" value="{$d.MemberID}" /></td>
                                <td>{$d.MemberID}</td>
                                <td>{$d.MemberName}</td>
                                <td>{$d.MemberRealName}</td>
                                
                                <td>{$d.MemberMobile}</td>
                                <td>{$d.MemberEmail}</td>
                                <td>{$d.MemberGroupName}</td>
                            </tr>
                        </volist>
                    <else/>
                    	<tr><td colspan="7" id="NoData">{$Think.lang.NoDataTip}</td></tr>
                    </notempty>                                
                    </table>
                         <div class="tfoot">
                              <div class="page"><span class="pagesize">每页<span class="pz">{$AdminPageSize}</span>条</span>{$Page}</div>
                         </div>
                    </div>
                </form>
</div>
</body>
</html>
<script type="text/javascript">
//查询
function Search(){
	$('#frm').attr("action", "__URL__/send");
	$('#frm').submit();
	return true;
}

//发放优惠券
function startSend(type){
	var params = {
		CouponID:"{$Coupon.CouponID}",
		CouponType:1
	};
	
	if(type == 1){  //按会员发放
		var MemberID = [];
		$("input[name='id[]']:checked").each(function(){ 
			MemberID.push( $(this).val() ); 
		 }); 
		
		if( MemberID.length == 0 ) {
			WarnBox("请选中会员!");
			return;
		}
		params.MemberID = MemberID.join(",");
	}else{  //按会员分组发放
		params.MemberGroupID = $("#MemberGroupID").val();
	}
	
	LoadBox();
	var url = "{$Url}startSend";
	$.get(url, params, function(data){
		CloseLoadBox();
		if (data.status==1){
			SucceedBox(data.info);
		}else{
			ErrorBox(data.info);
		}
	}, "json");
}
</script>